<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<title>病例</title>
<style type="text/css">

</style>
</head>
<script type="text/javascript">
 $(function() {
	//$(this).registerManagerPage();
 	initView();
});

function queryForm() {
	$("#blTable").datagrid("reload");
}

function initView()
{
	initDatagrid();
	$("#queryForm").attr("action","queryYlt.service");
	/**确认按钮*/
	$("#enter").on("click", function(){
		var row = $("#blTable").datagrid("getSelected");
		if(validateYlt(row)){
			StoreCache.setCache("FWGL_BLXX", row);
			parent.layer.closeAll("iframe");
		}
	});
	/**关闭按钮*/
	$("#close").on("click", function(){
		parent.layer.closeAll("iframe");
	});
}

function initDatagrid(){
	var cache = StoreCache.removeCache("FWGL_BLXX");
	var opt = {
				idField : "BLID",
				uniqueId : "BLID",
				striped : true,
				columns : [ [ 
				{
					field : "HZXM",
					width : 100,
					align : "center",
					title : "患者姓名"
				}, {
					field : "SFZH",
					width : 200,
					align : "center",
					title : "证件号码"
				}, {
					field : "ZDBM",
					width : 250,
					align : "center",
					title : "诊断编码"
				}, {
					field : "ZDMC",
					width : 200,
					align : "center",
					title : "诊断名称"
				},{
					field : "JZRQ",
					width : 100,
					align : "center",
					title : "就诊日期"
				},{
					field : "cz",
					width : 100,
					align : "center",
					title : "操作",
					formatter : function(value, row, index){
						return ($("#blDetail").html()).replace(/#blid#/g,row["BLID"]);
					}
				} ] ],
				pagination : true,
				pageNumber : 1,
				pageSize : 10,
				fit : true,
				fitColumns : true,
				singleSelect : true,
				rownumbers : true,
				method : "post",
				url : "queryBllb.service",
				onBeforeLoad : function(params)//加载之前回调 获取查询条件
				{
					params["HZXM"] = $("#HZXM").val();
					params["ZDMC"] = $("#ZDMC").val();
					params["JZJG"] = cache["YLJGID"];
					return params;
				},onLoadSuccess: function(data){ 
					/**选中已选行*/
					var blid = cache["BLID"];
					if(!StringUtils.isEmpty(blid)){
						$("#blTable").datagrid("selectRecord",blid);
					}
				}
			};
	/**加载机构*/
	$("#blTable").datagrid(opt);
}

/**机构详情*/
function blDetail(blid){
	window.open("blDetail.html?BLID="+ blid);
}

/**查询按钮*/
function btnQueryHandler(){
	queryDatagrid();
}

/**刷新datagrid*/
function queryDatagrid(){
	$("#blTable").datagrid("reload");
}

/**校验是否选择医联体*/
function validateYlt(row){
	var flag = false;
	if(StringUtils.isEmpty(row)){
		$.QuickAlert.alertFail({
			content : "请选择医联体！",
		});
	}else{
		flag = true;
	}
	return flag 
}
</script>

<body>
<div class="easyui-layout" fit="true" style="width: 100%;">
	<div region="north" style="border: none; overflow: hidden;">
	<h4 class="h4-title" style="font-size: 18px;">
		医联体信息列表
	</h4>
	</div>
	<div region="center" style="border: none;overflow: hidden;">
	<div class="easyui-layout" style="width:100%;border: none;height: 400px;" fit="true" id='dataGridDiv'>
		<div region="north" style="border: none;overflow: hidden;">
			<form id="queryForm"></form>
			<div id="dgFormToolbar" style="background: white;">
				<table class="form-table" style="">
					<tr>
						<td class="td-text">患者姓名：</td>
						<td class="td-content">
							<input id="HZXM" type="text" placeholder="患者姓名">
						</td>
						<td class="td-text">诊断名称：</td>
						<td class="td-content">
							<input id="ZDMC" type="text" placeholder="诊断名称">
						</td>
						<td class="td-text">
							<button class="btn btn-default" type="button"
							onclick="btnQueryHandler()">查询</button>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div region="center" style="border: none;height: 300px">
			<table id="blTable">
			</table> 
		</div>
	</div>
	</div>
	<div region="south" style="border: none;">
		<div style="float:right;height: 30px;margin-right: 10px;">
			<button type="button" id="enter">确认</button>
			&nbsp;
			<button type="button" id="close">关闭</button>
		</div>
	</div>
</div>
</body>
<script type="text/html" id="blDetail">
<a href="javascript:blDetail('#blid#')" title="详细" >详细</a>
</script>
</html>



